home *** CD-ROM | disk | FTP | other *** search
/ Just Call Me Internet / Just Call Me Internet.iso / prog / atari / m2 / cat3src / cat / windials.i < prev    next >
Text File  |  1997-10-26  |  24KB  |  803 lines

  1. IMPLEMENTATION MODULE WinDials;
  2. (*$Z+*)
  3. (*$H+*)
  4.  
  5. FROM SYSTEM IMPORT ADDRESS, CAST, ADR, LOC, CALLSYS, CADR;
  6.  
  7. FROM Storage    IMPORT ALLOCATE, DEALLOCATE;
  8.  
  9. IMPORT Strings;
  10.  
  11. IMPORT MagicAES, MagicVDI, mtDials, mtUtils, mtAppl, MagicStrings;
  12.  
  13. IMPORT GrafBase;
  14.  
  15. IMPORT WdwManager, MagicDOS;
  16.  
  17. IMPORT BinOps;
  18.  
  19. FROM Void   IMPORT v;
  20.  
  21. TYPE    
  22.         PtrWinDial  = POINTER TO WinDial;
  23.         
  24.         WinDial = RECORD
  25.                     tree    : ADDRESS;
  26.                     wdw     : INTEGER;
  27.                     hdlSet  : wdSetProc;
  28.                     hdlGet  : wdSetProc;
  29.                     hdlBut  : wdButtonProc;
  30.                     hdlDraw : wdDrawProc;
  31.                     private : ADDRESS;
  32.                     modal   : BOOLEAN;
  33.                     docpos  : GrafBase.Rectangle;
  34.                     oldFrame: CHAR;
  35.                     titleObj: INTEGER;
  36.                     wasOutl : BOOLEAN;
  37.                     editable: BOOLEAN;
  38.                     cursorDa: BOOLEAN;
  39.                     pos,
  40.                     edit    : INTEGER;
  41.                     exit    : INTEGER;
  42.                     start,
  43.                     depth   : INTEGER;  (* Fr Redraw von einzelnen Objekten *)
  44.                     next,
  45.                     prev    : PtrWinDial;
  46.                   END;
  47.  
  48.  
  49. VAR dials       : PtrWinDial;
  50.     dialExit    : BOOLEAN;
  51.     dialReturn  : INTEGER;
  52.     apName      : Strings.String;
  53.     winAlerts   : BOOLEAN;
  54.     originalDialDo: mtDials.DialDoProc;
  55.  
  56.  
  57. (* Interface-Prozeduren zum WindowManager *)
  58.  
  59. PROCEDURE winDialDraw (wdw, vdi: INTEGER; special: ADDRESS; clip: GrafBase.Rectangle);
  60.   VAR dialPtr : PtrWinDial;
  61.       cr      : GrafBase.Rectangle;
  62.       c2      : GrafBase.Rectangle;
  63.       cursorWarDa : BOOLEAN;
  64. BEGIN
  65.   dialPtr := special;
  66.   WITH dialPtr^ DO
  67.     cr := clip;
  68.     mtUtils.AbsRect (cr);
  69.     cursorWarDa := cursorDa;
  70.     IF editable & (WdwManager.theTopWindow = wdw) & cursorDa
  71.     THEN
  72.       WdwManager.SetClip (mtAppl.PrivateWS, cr, FALSE);
  73.       mtDials.ObjcEdit (tree, edit, pos, 0, MagicAES.EDEND);
  74.       cursorDa := FALSE;
  75.       MagicVDI.SetClipping (mtAppl.PrivateWS, cr, FALSE);
  76.     END;
  77.     mtDials.DialDraw (tree, start, depth, clip, TRUE);
  78.     IF dialPtr^.hdlDraw # wdDrawProc (NIL)
  79.     THEN
  80.       dialPtr^.hdlDraw (tree, private, clip);
  81.     END;
  82.     IF editable & (WdwManager.theTopWindow = wdw) & ~cursorDa & cursorWarDa
  83.     THEN
  84.       WdwManager.SetClip (mtAppl.PrivateWS, cr, FALSE);
  85.       mtDials.ObjcEdit (tree, edit, pos, 0, MagicAES.EDINIT);
  86.       cursorDa := TRUE;
  87.       MagicVDI.SetClipping (mtAppl.PrivateWS, cr, FALSE);
  88.     END; 
  89.   END;
  90. END winDialDraw;
  91.  
  92. PROCEDURE winDialTop (wdw, vdi: INTEGER; special: ADDRESS): BOOLEAN;
  93.   VAR dialPtr : PtrWinDial;
  94. BEGIN
  95.   dialPtr := special;
  96.   WITH dialPtr^ DO
  97.     IF editable & ~cursorDa & ~WdwManager.WindowIsShaded (wdw)
  98.     THEN
  99.       mtDials.ObjcEdit (tree, edit, pos, 0, MagicAES.EDINIT);
  100.       cursorDa := TRUE;
  101.     END; 
  102.   END;
  103.   RETURN TRUE;
  104. END winDialTop;
  105.  
  106. PROCEDURE winDialUntop (wdw, vdi: INTEGER; special: ADDRESS);
  107.   VAR dialPtr : PtrWinDial;
  108. BEGIN
  109.   dialPtr := special;
  110.   WITH dialPtr^ DO
  111.     IF editable & cursorDa & ~WdwManager.WindowIsShaded (wdw)
  112.     THEN
  113.       mtDials.ObjcEdit (tree, edit, pos, 0, MagicAES.EDEND);
  114.       cursorDa := FALSE;
  115.     END; 
  116.   END;
  117. END winDialUntop;
  118.  
  119. PROCEDURE winDialHide (wdw, vdi: INTEGER; special: ADDRESS; hide: BOOLEAN);
  120.   VAR dialPtr : PtrWinDial;
  121. BEGIN
  122.   (*
  123.   dialPtr := special;
  124.   WITH dialPtr^ DO
  125.     IF hide 
  126.     THEN
  127.       winDialUntop (wdw, vdi, special);
  128.     ELSE
  129.       v.bool := winDialTop (wdw, vdi, special);
  130.     END;
  131.   END;
  132.   *)
  133. END winDialHide;
  134.  
  135. PROCEDURE winDialGetArea (wdw, vdi: INTEGER; special: ADDRESS; VAR work: GrafBase.Rectangle);
  136.   VAR dialPtr : PtrWinDial;
  137.       obr     : GrafBase.Rectangle;
  138. BEGIN
  139.   dialPtr := special;
  140.   WITH dialPtr^ DO
  141.     (* Objectposition anpassen an neuen Workbereich *)
  142.     mtUtils.ObjcArea (tree, 0, obr);
  143.     obr.x := work.x - docpos.x;
  144.     obr.y := work.y - docpos.y;
  145.     mtUtils.SetObjcRect (tree, 0, obr);
  146.   END;
  147. END winDialGetArea;
  148.  
  149. PROCEDURE winDialClose (wdw, vdi: INTEGER; special: ADDRESS; force: BOOLEAN): BOOLEAN;
  150.   VAR dialPtr : PtrWinDial;
  151. BEGIN
  152.   dialPtr := special;
  153.   WITH dialPtr^ DO
  154.     hdlGet (tree, private, FALSE, exit);
  155.     (* dialogExit auf TRUE setzen *)
  156.     dialExit := TRUE;
  157.     (* Dialog freigeben *)
  158.     mtDials.DisposeDial (tree);
  159.   END;
  160.   (* Aus der Liste aush„ngen *)
  161.   IF dialPtr^.next # NIL
  162.   THEN
  163.     dialPtr^.next^.prev := dialPtr^.prev;
  164.   END;
  165.   IF dialPtr^.prev # NIL
  166.   THEN
  167.     dialPtr^.prev^.next := dialPtr^.next;
  168.   END;
  169.   IF dials = dialPtr 
  170.   THEN
  171.     dials := dialPtr^.next;
  172.   END;
  173.   DISPOSE (dialPtr);
  174.   RETURN TRUE;
  175. END winDialClose;
  176.  
  177. (* Interface-Prozeduren zum WindowManager: Objectbehandlung *)
  178.  
  179. PROCEDURE winDialButton (wdw, vdi: INTEGER; special: ADDRESS; mx, my : INTEGER;
  180.                          kstate, buttons: BITSET; clicks: INTEGER): BOOLEAN;
  181.   VAR dialPtr : PtrWinDial;
  182.         exitDial: BOOLEAN;
  183.       entry   : INTEGER;
  184.       scan,
  185.       taste   : INTEGER;
  186.       char    : CHAR;
  187. BEGIN
  188.   dialPtr := special;
  189.   WITH dialPtr^ DO
  190.     IF wdw # WdwManager.theTopWindow THEN RETURN FALSE END;
  191.     IF WdwManager.WindowIsShaded (wdw) THEN RETURN FALSE END;
  192.     EXCL(buttons, MagicAES.MouseRight);  (* rechte Taste brauchen wir nicht *)
  193.     entry := -1;
  194.     taste := 0;
  195.     scan := 0;
  196.     char := 0C;
  197.     IF mtDials.HandleEvent (BITSET{MagicAES.MUBUTTON}, mx, my,
  198.                            buttons, taste, kstate, scan, char,
  199.                            clicks, tree, editable, edit,
  200.                            pos, entry)
  201.     THEN
  202.       IF clicks > 1
  203.       THEN
  204.         entry := INTEGER(BITSET(entry) + {15});
  205.       END;
  206.       exit := entry;
  207.       IF editable & cursorDa THEN  mtDials.ObjcEdit (tree, edit, pos, 0, MagicAES.EDEND); cursorDa := FALSE; END;
  208.       exitDial := hdlBut (tree, private, entry, mx, my, kstate, clicks);
  209.       IF editable & ~cursorDa THEN  mtDials.ObjcEdit (tree, edit, pos, 0, MagicAES.EDINIT); cursorDa := TRUE; END;
  210.       IF exitDial & editable
  211.       THEN
  212.         IF cursorDa THEN 
  213.           mtDials.ObjcEdit (tree, edit, pos, 0, MagicAES.EDEND); 
  214.         END;
  215.         cursorDa := FALSE;
  216.       END;
  217.       IF exitDial 
  218.       THEN
  219.         CloseWinDial (tree);
  220.       END;
  221.       (* Exitbutton zurcksetzen *)
  222.       exit := -1;
  223.       (* An Windowmanager zurckgeben, daž wir den behandelt haben *)
  224.       RETURN TRUE;
  225.     END;
  226.   END;
  227.   RETURN FALSE;
  228. END winDialButton;
  229.  
  230. PROCEDURE winDialKey (wdw, vdi: INTEGER; special: ADDRESS; taste: INTEGER; key, scan: CHAR; kstate: BITSET): BOOLEAN;
  231.   VAR dialPtr : PtrWinDial;
  232.       exitDial: BOOLEAN;
  233.       entry   : INTEGER;
  234.       mx, my  : INTEGER;
  235.       clicks  : INTEGER;
  236.       sc      : INTEGER;
  237.       buts    : BITSET;
  238. BEGIN
  239.   dialPtr := special;
  240.   WITH dialPtr^ DO
  241.     IF wdw # WdwManager.theTopWindow THEN RETURN FALSE END;
  242.     IF WdwManager.WindowIsShaded (wdw) THEN RETURN FALSE END;
  243.     entry := -1;
  244.     buts := {};
  245.     clicks := 0; mx := 0; my := 0;
  246.     sc := ORD (scan);
  247.     IF mtDials.HandleEvent (BITSET{MagicAES.MUKEYBD}, mx, my,
  248.                          buts, taste, kstate, sc, key,
  249.                          clicks, tree, editable, edit,
  250.                          pos, entry)
  251.     THEN
  252.       exit := entry;
  253.       IF editable & cursorDa THEN  mtDials.ObjcEdit (tree, edit, pos, 0, MagicAES.EDEND); cursorDa := FALSE; END;
  254.       exitDial := hdlBut (tree, private, entry, mx, my, kstate, clicks);
  255.       IF editable & ~cursorDa THEN  mtDials.ObjcEdit (tree, edit, pos, 0, MagicAES.EDINIT); cursorDa := TRUE; END;
  256.       IF exitDial & editable
  257.       THEN
  258.         IF cursorDa THEN mtDials.ObjcEdit (tree, edit, pos, 0, MagicAES.EDEND); END;
  259.         cursorDa := FALSE;
  260.       END;
  261.       IF exitDial 
  262.       THEN
  263.         CloseWinDial (tree);
  264.       END;
  265.       (* Exitbutton zurcksetzen *)
  266.       exit := -1;
  267.       (* An Windowmanager zurckgeben, daž wir den behandelt haben *)
  268.       RETURN TRUE;
  269.     ELSE
  270.       (* An Windowmanager zurckgeben, ob wir den behandelt haben.
  271.        * Wenn durch den Tastendruck nur ein Object selektiert wurde,
  272.        * dann wird entry auf diesen Eintrag gesetzt
  273.        *)
  274.       RETURN (entry > 0) OR modal;
  275.     END;
  276.   END;
  277.   RETURN FALSE;
  278. END winDialKey;
  279.  
  280. PROCEDURE PrepareWinDial (wd: PtrWinDial; VAR work: GrafBase.Rectangle; VAR name: ARRAY OF CHAR);
  281. (* Positioniert den Dialog und holt den Titel 
  282.  *)
  283.   
  284.   CONST CutHeight = 24;    (* abzuschneidendes oberes Stck (Flyer und Titel) *)
  285.  
  286.   VAR
  287.         extyp1, 
  288.         extyp2, 
  289.         typ     : INTEGER;
  290.         obr,
  291.         docpos  : GrafBase.Rectangle;
  292.         box     : mtUtils.tObjcTree;
  293. BEGIN
  294.   WITH wd^ DO
  295.     
  296.     (* Outlined abschalten und Rand auf 1 Pixel setzen *)
  297.     
  298.     wasOutl := mtUtils.InState (tree, 0, MagicAES.OUTLINED);
  299.     IF wasOutl
  300.     THEN
  301.       mtUtils.ExclState(tree, 0, MagicAES.OUTLINED);
  302.       box := tree;
  303.       oldFrame := box^[0].obSpec.Box.frame;
  304.       box^[0].obSpec.Box.frame := CAST(CHAR, -1);
  305.     END;
  306.     
  307.     mtDials.DialCenter (tree, mtDials.CSCREEN, v.int, v.int, work);
  308.     mtUtils.ObjcArea (tree, 0, work);
  309.     docpos := work;
  310.     docpos.x := 0;
  311.  
  312.     (* Haben wir einen Flyer und einen Titel?
  313.      * Dann sollten wir den oberen Rand abschneiden *)
  314.     mtDials.GetObjcExtype(tree, 1, extyp1, typ);
  315.     mtDials.GetObjcExtype(tree, 2, extyp2, typ);
  316.     IF (extyp1 = mtDials.MoveBox) AND (extyp2 = mtDials.SpecText)
  317.     OR (extyp2 = mtDials.MoveBox) AND (extyp1 = mtDials.SpecText)
  318.     THEN
  319.       (* oberen Rand abschneiden (Flyer und Titel) *)
  320.       docpos.y := (mtAppl.CharHeight * 2) ; (* CutHeight; *)
  321.     ELSE
  322.       (* Finger davon, solange kein Titel und Flyer da sind *)
  323.       docpos.y := 0;
  324.     END;
  325.     
  326.     DEC (work.h, docpos.y);   (* abgeschnittenen Rand von Fl„che abziehen *)
  327.     INC (work.y, docpos.y DIV 2);   (* Nochmal zentrieren *)
  328.         
  329.     (* Objectposition anpassen an neuen Workbereich *)
  330.     mtUtils.ObjcArea (tree, 0, obr);
  331.     obr.x := work.x - docpos.x;
  332.     obr.y := work.y - docpos.y;
  333.     
  334.     mtUtils.SetObjcRect (tree, 0, obr);
  335.  
  336.     IF extyp2 = mtDials.SpecText
  337.     THEN
  338.       mtUtils.ObjcString(tree, 2, name);   (* Dialogtitel immer Objekt 2 *)
  339.       titleObj := 2;
  340.     ELSIF extyp1 = mtDials.SpecText
  341.     THEN
  342.       mtUtils.ObjcString(tree, 1, name);   (* Dialogtitel immer Objekt 1 *)
  343.       titleObj := 1;
  344.     ELSE
  345.       MagicStrings.Assign ("", name);      (* Kein Name, bergebenen Namen nehmen *)
  346.     END;
  347.     (* Leerzeichen abschneiden *)
  348.     Strings.DelTrailingBlanks (name);
  349.     Strings.DelLeadingBlanks (name);
  350.     IF (extyp1 = mtDials.MoveBox)
  351.     OR (extyp1 = mtDials.SpecText)
  352.     THEN
  353.       (* Objekte verstecken *)
  354.       mtUtils.InclFlag (tree, 1, MagicAES.HIDETREE);
  355.       IF ((extyp2 = mtDials.SpecText) 
  356.        OR (extyp2 = mtDials.MoveBox))
  357.        &  (extyp1 # extyp2)
  358.       THEN
  359.         mtUtils.InclFlag (tree, 2, MagicAES.HIDETREE);
  360.       END;
  361.     END;
  362.   END;
  363. END PrepareWinDial;
  364.  
  365. PROCEDURE RestoreWinDial (wd: PtrWinDial);
  366.   VAR   box     : mtUtils.tObjcTree;
  367.         extyp1, 
  368.         extyp2, 
  369.         typ     : INTEGER;
  370. BEGIN
  371.   (* Setzt die Outline und den Rahmen wieder zurck *)
  372.   WITH wd^ DO
  373.     IF wasOutl
  374.     THEN
  375.       mtUtils.InclState (tree, 0, MagicAES.OUTLINED);
  376.       box := tree;
  377.       box^[0].obSpec.Box.frame := oldFrame;
  378.     END;
  379.     mtDials.GetObjcExtype(tree, 1, extyp1, typ);
  380.     mtDials.GetObjcExtype(tree, 2, extyp2, typ);
  381.     IF extyp1 = mtDials.MoveBox
  382.     THEN
  383.       (* Objekte nicht mehr verstecken *)
  384.       mtUtils.ExclFlag (tree, 1, MagicAES.HIDETREE);
  385.       IF extyp2 = mtDials.SpecText
  386.       THEN
  387.         mtUtils.ExclFlag (tree, 2, MagicAES.HIDETREE);
  388.       END;
  389.     END;
  390.   END;
  391. END RestoreWinDial;
  392.  
  393. PROCEDURE FindWinDial (tree: ADDRESS): PtrWinDial;
  394.   VAR wdwPtr : PtrWinDial;
  395. BEGIN
  396.   wdwPtr := dials;
  397.   WHILE (wdwPtr # NIL) & (wdwPtr^.tree # tree) DO wdwPtr := wdwPtr^.next END;
  398.   RETURN wdwPtr;
  399. END FindWinDial;
  400.  
  401. PROCEDURE OpenWinDial (tr: ADDRESS;
  402.                        isModal  : BOOLEAN;
  403.                        setValues: wdSetProc;
  404.                        getValues: wdSetProc;
  405.                        button   : wdButtonProc;
  406.                        draw     : wdDrawProc;
  407.                        REF title    : ARRAY OF CHAR;
  408.                        priv     : ADDRESS): BOOLEAN;
  409. (* Erzeugt einen Dialog im Fenster. 
  410.  * Wenn der Dialog schon in einem Fenster ist, dann
  411.  * wird er getoppt.
  412.  * Ansonsten wird ein neues Fenster angelegt, setValues aufgerufen,
  413.  * um die Werte zu setzen, und dann wird das Fenster ge”ffnet und
  414.  * angezeigt. Falls der Dialog modal ist, wird das Menu
  415.  * disablet.
  416.  * False: Fensterdialog konnte nicht angelegt werden
  417.  *)
  418.  VAR work   : GrafBase.Rectangle;
  419.      wdwCurr: GrafBase.Rectangle;
  420.      obr    : GrafBase.Rectangle;
  421.      comps  : BITSET;
  422.      dialPtr    : PtrWinDial;
  423.      name   : ARRAY [0..79] OF CHAR;
  424.      
  425. BEGIN
  426.   (* Suchen, ob schon WinDial vorhanden *)
  427.   dialPtr := FindWinDial (tr);
  428.   IF dialPtr # NIL
  429.   THEN
  430.     WdwManager.TopWindow (dialPtr^.wdw);
  431.     RETURN TRUE;
  432.   END;
  433.   (* Noch nicht vorhanden, also neuen anlegen *)
  434.   NEW (dialPtr);
  435.   IF dialPtr = NIL
  436.   THEN 
  437.     RETURN FALSE
  438.   END;
  439.   (* Neuen Dialog anlegen *)
  440.   IF ~mtDials.NewDial (tr)
  441.   THEN
  442.     DISPOSE (dialPtr);
  443.     RETURN FALSE;
  444.   END;
  445.   (* Fenster anlegen und ”ffnen *)
  446.   comps := BITSET{MagicAES.NAME, MagicAES.MOVE};
  447.   IF ~isModal
  448.   THEN
  449.     INCL(comps, MagicAES.CLOSER);
  450.   END;
  451.   IF ~WdwManager.CreateWindow (WdwManager.deskSize, work, comps,
  452.                                "", "", dialPtr, TRUE, FALSE,
  453.                                dialPtr^.wdw, v.int)
  454.   THEN
  455.     mtDials.DisposeDial (tr);
  456.     DISPOSE (dialPtr);
  457.     RETURN FALSE;
  458.   END;
  459.   IF ~WdwManager.SetWindowMode (dialPtr^.wdw, isModal)
  460.   THEN
  461.     mtDials.DisposeDial (tr);
  462.     DISPOSE (dialPtr);
  463.     RETURN FALSE;
  464.   END;
  465.   WITH dialPtr^ DO
  466.     tree := tr;
  467.     hdlSet := setValues;
  468.     hdlGet := getValues;
  469.     hdlBut := button;
  470.     hdlDraw:= draw;
  471.     modal  := isModal;
  472.     private := priv;
  473.     depth := 99;
  474.     start := 0;
  475.     exit  := -1;
  476.     titleObj := -1;
  477.   END;
  478.  
  479.   (* Jetzt den Dialog vorbereiten, Titel und richtige Gr”že setzen 
  480.    *)
  481.   PrepareWinDial (dialPtr, work, name);
  482.   IF name[0] = ''
  483.   THEN
  484.     MagicStrings.Assign (title, name);
  485.     Strings.DelTrailingBlanks (name);
  486.   END;
  487.   IF LENGTH(name) = 0
  488.   THEN
  489.     MagicStrings.Assign (apName, name);
  490.   END;
  491.   (* Jetzt die Windowspezifischen Sachen einh„ngen *)
  492.   WITH dialPtr^ DO
  493.     (* Ein kleiner Koordinatencheck *)
  494.     MagicAES.WindCalc (MagicAES.WCBORDER, comps, work, wdwCurr);
  495.     wdwCurr.y := BinOps.HigherInt (wdwCurr.y, WdwManager.deskSize.y);
  496.     MagicAES.WindCalc (MagicAES.WCWORK, comps, wdwCurr, work);
  497.  
  498.     (* Objectposition anpassen an neuen Workbereich *)
  499.     mtUtils.ObjcArea (tree, 0, obr);
  500.     obr.x := work.x - docpos.x;
  501.     obr.y := work.y - docpos.y;
  502.     mtUtils.SetObjcRect (tree, 0, obr);
  503.  
  504.     WdwManager.SetWdwWork (wdw, work);
  505.     WdwManager.SetWdwTitle (wdw, name);
  506.     v.bool := WdwManager.SetWindowButton (wdw, winDialButton);
  507.     v.bool := WdwManager.SetWindowKey (wdw, winDialKey);
  508.     v.bool := WdwManager.SetWindowDraw (wdw, winDialDraw);
  509.     v.bool := WdwManager.SetWindowTop (wdw, winDialTop);
  510.     v.bool := WdwManager.SetWindowUntop (wdw, winDialUntop);
  511.     v.bool := WdwManager.SetWindowClose (wdw, winDialClose);
  512.     v.bool := WdwManager.SetWindowHide (wdw, winDialHide);
  513.     v.bool := WdwManager.SetWindowDial (wdw, tree);
  514.     v.bool := WdwManager.SetWindowGetScroll (wdw, winDialGetArea);
  515.   END;
  516.   (* So, jetzt noch in Liste einh„ngen *)
  517.   dialPtr^.prev := NIL;
  518.   IF dials = NIL
  519.   THEN
  520.     dialPtr^.next := NIL;
  521.   ELSE
  522.     (* Am Anfang einh„ngen *)
  523.     dialPtr^.next := dials;
  524.     dials^.prev := dialPtr;
  525.   END;
  526.   dials := dialPtr;
  527.   (* Und jetzt zeigen wir das Fenster an *)
  528.   WITH dialPtr^ DO
  529.     mtDials.PrepDial (tree, 0, editable, pos, edit);
  530.     hdlSet (tree, private, TRUE, -1);
  531.     cursorDa := FALSE;
  532.     v.bool := WdwManager.ShowWindow (wdw);
  533.   END;
  534.   RETURN TRUE
  535. END OpenWinDial;
  536.  
  537. PROCEDURE CloseWinDial (tree: ADDRESS);
  538. (* schliežt einen Fensterdialog. getValues wird aufgerufen.
  539.  *)
  540.    VAR dialPtr: PtrWinDial;
  541. BEGIN
  542.   (* Suchen, ob schon WinDial vorhanden *)
  543.   dialPtr := FindWinDial (tree);
  544.   IF dialPtr # NIL
  545.   THEN
  546.     RestoreWinDial (dialPtr);
  547.     v.bool := WdwManager.CloseWindow (dialPtr^.wdw, FALSE);
  548.   END;
  549. END CloseWinDial;
  550.  
  551. PROCEDURE FormHandle(form : ADDRESS; edit: INTEGER):INTEGER;
  552. VAR exit   : INTEGER;
  553. BEGIN
  554.   IF ~mtDials.NewDial (form)
  555.   THEN
  556.     RETURN -1;
  557.   END;
  558.   MagicAES.WindUpdate (MagicAES.BEGUPDATE);
  559.   mtDials.DialCenter(form, mtDials.CSCREEN, 0,0, v.r);
  560.   mtDials.DialForm(form, mtDials.DSTART, v.r, v.r);
  561.   mtDials.DialDraw(form, 0,200, v.r, FALSE);
  562.   IF winAlerts
  563.   THEN
  564.     exit := originalDialDo(form, edit);
  565.   ELSE
  566.     exit := mtDials.DialDo (form, edit);
  567.   END;
  568.   exit := INTEGER(BITSET(exit) - {15});
  569.   mtDials.DialForm(form, mtDials.DFINISH, v.r, v.r);
  570.   mtUtils.ExclState(form, exit, MagicAES.SELECTED);
  571.   mtDials.DisposeDial (form);
  572.   MagicAES.WindUpdate (MagicAES.ENDUPDATE);
  573.   RETURN exit
  574. END FormHandle;
  575.  
  576. PROCEDURE defDraw (tree, private: ADDRESS; clip: GrafBase.Rectangle);
  577. END defDraw;
  578.  
  579. PROCEDURE defSet (tree, private: ADDRESS; set: BOOLEAN; exitBut: INTEGER);
  580. END defSet;
  581.  
  582. PROCEDURE defButton (tree, private: ADDRESS; obj: INTEGER;
  583.                      mx, my: INTEGER; kstate : BITSET; 
  584.                      clicks: INTEGER): BOOLEAN;
  585. BEGIN
  586.   mtUtils.ExclState (tree, obj, MagicAES.SELECTED);
  587.   dialExit := TRUE;
  588.   dialReturn := obj;
  589.   RETURN TRUE;
  590. END defButton;
  591.  
  592. PROCEDURE WinDialDraw (tree: ADDRESS; entry, dpth: INTEGER;
  593.                        clip: ARRAY OF LOC; clipping: BOOLEAN);
  594.   VAR pr: POINTER TO GrafBase.Rectangle;
  595.       r : GrafBase.Rectangle;
  596.       dialPtr: PtrWinDial;
  597. BEGIN
  598.   (* Suchen, ob schon WinDial vorhanden *)
  599.   dialPtr := FindWinDial (tree);
  600.   IF dialPtr # NIL
  601.   THEN
  602.     WITH dialPtr^ DO  
  603.       depth := dpth;
  604.       start := entry;
  605.       IF clipping
  606.       THEN
  607.         pr := ADR (clip);
  608.         WdwManager.RedrawWdw (wdw, pr^)
  609.       ELSE
  610.         mtUtils.CalcArea (tree, entry, r);
  611.         WdwManager.RedrawWdw (wdw, r);
  612.       END;
  613.       depth := 99;
  614.       start := 0;
  615.     END;
  616.   ELSE
  617.     mtDials.DialDraw (tree, entry, dpth, clip, clipping);
  618.   END;
  619. END WinDialDraw;
  620.  
  621. PROCEDURE WinDialHandleEvents ();
  622. (* Durchl„uft die Eventloop, bis das Topwindow mit dem aktuellen Dialog
  623.  * geschlossen wird
  624.  *)
  625.  VAR Events : BITSET;
  626.      clicks,
  627.      taste,
  628.      mx, my : INTEGER;
  629.      buts,
  630.      kstate : BITSET;
  631.      event  : BITSET;
  632.      mBuff  : ARRAY [0..7] OF INTEGER;
  633.      scan   : INTEGER;
  634.      sc,
  635.      key    : CHAR;
  636. BEGIN
  637.   dialExit := FALSE;
  638.   dialReturn := -1;
  639.   
  640.   WdwManager.DisableMenu (NIL, TRUE);
  641.   
  642.   Events := BITSET{MagicAES.MUKEYBD, MagicAES.MUBUTTON, MagicAES.MUMESAG};
  643.  
  644.   MagicAES.WindUpdate (MagicAES.ENDUPDATE);
  645.   LOOP
  646.     event := MagicAES.EvntMulti(Events,
  647.                          2,  BITSET{MagicAES.MouseLeft},
  648.                              BITSET{MagicAES.MouseLeft},
  649.                          0, GrafBase.Rectangle{0,0,0,0},
  650.                          0, GrafBase.Rectangle{0,0,0,0},  (* Mouse2Rect      *)
  651.                          mBuff,
  652.                          0, 0,             (* Timerdauer      *)
  653.                          mx, my,           (* Maus-Position   *)
  654.                          buts,             (* Maus-Buttons    *)
  655.                          taste,            (* gedrckte Taste *)
  656.                          kstate,           (* Shift-state     *)
  657.                          scan,             (* scan-code       *)
  658.                          key,              (* ascii-code      *)
  659.                          clicks);          (* Klick-Anzahl    *)
  660.     sc := CHR(scan);
  661.     MagicAES.WindUpdate (MagicAES.BEGUPDATE);
  662.     v.bool := WdwManager.HandleEvent (event, mBuff, buts, kstate, key, sc,
  663.                                       taste, mx, my, clicks);
  664.     MagicAES.WindUpdate (MagicAES.ENDUPDATE);
  665.     IF dialExit THEN EXIT END; 
  666.   END;
  667.   dialExit := FALSE;
  668.   MagicAES.WindUpdate (MagicAES.BEGUPDATE);
  669.   WdwManager.DisableMenu (NIL, FALSE);
  670. END WinDialHandleEvents;
  671.  
  672. PROCEDURE WinDialDo (tree: ADDRESS; edit: INTEGER): INTEGER;
  673. (* Fhrt einen kompletten modalen Fensterdialog durch. Es wird
  674.  * der Button zurckgegeben, mit dem der Dialog verlassen wurde.
  675.  * Wenn kein Fenster mehr frei ist, wird ein normaler Dialog gezeichnet
  676.  *)
  677. BEGIN
  678.   IF ~OpenWinDial (tree, TRUE, defSet, defSet, defButton, defDraw, "", NIL)
  679.   THEN
  680.     (* normalen Dialog durchfhren *)
  681.     RETURN FormHandle (tree, edit);
  682.   END;
  683.   WinDialHandleEvents();
  684.   RETURN dialReturn;
  685. END WinDialDo;
  686.  
  687. PROCEDURE WinDialIsTop (wdw: INTEGER): BOOLEAN;
  688. (* Fragt nach, ob das Fenster wdw ein Fensterdialog ist 
  689.  *)
  690.   VAR wdwPtr : PtrWinDial;
  691. BEGIN
  692.   wdwPtr := dials;
  693.   WHILE (wdwPtr # NIL) & (wdwPtr^.wdw # wdw) DO wdwPtr := wdwPtr^.next END;
  694.   RETURN wdwPtr # NIL;
  695. END WinDialIsTop;
  696.  
  697. PROCEDURE SetApplicationName (REF name : ARRAY OF CHAR);
  698. BEGIN
  699.   MagicStrings.Assign (name, apName);
  700. END SetApplicationName;
  701.  
  702. PROCEDURE WinEditChanged (tree: ADDRESS; newEdit: INTEGER);
  703. (* Setzt den Cursor in ein neues Editfeld bzw. teilt dem Modul
  704.  * mit, daž sich der Text ge„ndert hat und daž der Cursor neu plaziert 
  705.  * werden soll. edit = -1: Nur Cursor neu plazieren.
  706.  *)
  707.    VAR dialPtr: PtrWinDial;
  708.        cursorWarDa: BOOLEAN;
  709. BEGIN
  710.   (* Suchen, ob schon WinDial vorhanden *)
  711.   dialPtr := FindWinDial (tree);
  712.   IF dialPtr # NIL
  713.   THEN
  714.     WITH dialPtr^ DO
  715.       IF editable
  716.       THEN
  717.         cursorWarDa := cursorDa;
  718.         IF cursorDa
  719.         THEN
  720.           mtDials.ObjcEdit (tree, edit, pos, 0, MagicAES.EDEND);
  721.           cursorDa := FALSE;
  722.         END;
  723.         IF (newEdit >= 0)
  724.         THEN
  725.           edit := newEdit;
  726.         END;
  727.         pos := -1;
  728.         IF cursorWarDa
  729.         THEN
  730.           mtDials.ObjcEdit (tree, edit, pos, 0, MagicAES.EDINIT);
  731.           cursorDa := TRUE;
  732.         END;
  733.       END;
  734.     END;
  735.   END;
  736. END WinEditChanged;
  737.  
  738. PROCEDURE WinUpdateTitle (tree: ADDRESS);
  739.    VAR dialPtr: PtrWinDial;
  740.        name   : ARRAY [0..79] OF CHAR;
  741. BEGIN
  742.   (* Suchen, ob schon WinDial vorhanden *)
  743.   dialPtr := FindWinDial (tree);
  744.   IF dialPtr # NIL
  745.   THEN
  746.     WITH dialPtr^ DO
  747.       IF titleObj >= 0
  748.       THEN
  749.         mtUtils.ObjcString(tree, titleObj, name);   (* Dialogtitel immer Objekt 2 *)
  750.  
  751.         Strings.DelTrailingBlanks (name);
  752.         Strings.DelLeadingBlanks (name);
  753.         WdwManager.SetWdwTitle (wdw, name);
  754.       END;
  755.     END;
  756.   END;
  757. END WinUpdateTitle;
  758.  
  759. PROCEDURE IsWinDial (tree: ADDRESS): BOOLEAN;
  760. (* Fragt nach, ob der Dialog schon in einem Fenster ist
  761.  *)
  762.    VAR dialPtr: PtrWinDial;
  763. BEGIN
  764.   (* Suchen, ob schon WinDial vorhanden *)
  765.   dialPtr := FindWinDial (tree);
  766.   RETURN dialPtr # NIL;
  767. END IsWinDial;
  768.  
  769. PROCEDURE ActivateWinDial (tree: ADDRESS);
  770. (* Aktiviert den Window-Dialog, falls vorhanden 
  771.  *)
  772.    VAR dialPtr: PtrWinDial;
  773. BEGIN
  774.   (* Suchen, ob schon WinDial vorhanden *)
  775.   dialPtr := FindWinDial (tree);
  776.   IF dialPtr # NIL
  777.   THEN
  778.     WdwManager.TopWindow (dialPtr^.wdw);
  779.   END;
  780. END ActivateWinDial;
  781.  
  782. PROCEDURE AlertsInWindow (doIt: BOOLEAN);
  783. BEGIN
  784.   IF (doIt = TRUE) & (winAlerts = FALSE)
  785.   THEN
  786.     originalDialDo := mtDials.OverloadDialDo (WinDialDo);
  787.     winAlerts := TRUE;
  788.   ELSIF (doIt = FALSE) & (winAlerts = TRUE)
  789.   THEN
  790.     winAlerts := FALSE;
  791.     originalDialDo := mtDials.OverloadDialDo (mtDials.DialDoProc(NIL));
  792.   END;
  793. END AlertsInWindow;
  794.  
  795. BEGIN
  796.   dials := NIL;
  797.   apName := "";  
  798.   winAlerts := FALSE;
  799.   (*
  800.   originalDialDo := mtDials.OverloadDialDo (WinDialDo);
  801.   *)
  802. END WinDials.
  803.